package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.springdate.domain.Users;
import com.example.springdate.dto.UserService;
import com.example.util.ResponseData;

@Controller
@RequestMapping("/users")
public class UserController {
	   @Autowired
	   UserService us;
      @RequestMapping(value="/insert",method=RequestMethod.POST)
	  public @ResponseBody ResponseData find1(@ModelAttribute  Users users){
		  ResponseData rd=new ResponseData();
		  rd.setErrorCode("0");
		  us.save(users);
		  rd.setValue(users);
		  return rd;
	  }
      @RequestMapping(value="/find",method=RequestMethod.POST)
      public @ResponseBody ResponseData find2(@RequestParam("id") String id){
		  ResponseData rd=new ResponseData();
		  rd.setErrorCode("0");
		  Users users=us.getByid2(id);
		  rd.setValue(users);
		  return rd;
	  }
      
}
